@extends("admin.layout.common")
@section('content')
    <link rel="stylesheet" href="{{asset('css/finance/sub-accountStatement_route.css')}}">
    <div class="content">
        <h1 class="h1">财务分账中心</h1>
        <!-- 公共结束 -->
        <div class="content_child">
            <p class="p1">
                <label for="">分账类型：</label>
                <select name="account-type" id="account-type">
                    <option @if($type == 0) selected @endif value="0">选择分账类型</option>
                    <option @if($type == 1) selected @endif value="1">音乐人/代理分账</option>
                    <option @if($type == 2) selected @endif value="2">指定分账</option>
                </select>
            </p>
            <p style="text-align: right;margin-bottom:20px;"><a href="{{url('admin/ledgerRecord/0')}}"><button type="button" class="btn history">历史分账记录</button></a></p>
            <div class="table_box">
                @foreach($accounts as $account)
                    @if(($type == 0 || $type == 1) && $account->music_status == 0 && ($account->music_total!=0 || $account->agent_total!=0))
                        <table border="1">
                            <tr>
                                <th>分账ID</th>
                                <th>分账期间</th>
                                <th>内部支出</th>
                                <th>分账总金额</th>
                                <th>分账类型</th>
                                <th>音乐人分账总金额</th>
                                <th>明细</th>
                            </tr>
                            <tr>
                                <td>{{$account->id}}</td>
                                <td>{{$account->time}}</td>
                                <td>{{$account->cost_total}}</td>
                                <td>{{$account->sp_total}}</td>
                                <td>音乐人分账</td>
                                <td>{{$account->music_total}}</td>
                                <td>
                                    <a href="/admin/examineBill/{{$account->time}}/music">点击查看</a>
                                </td>
                            </tr>
                            <tr>
                                <td>{{$account->id}}</td>
                                <td>{{$account->time}}</td>
                                <td>{{$account->cost_total}}</td>
                                <td>{{$account->sp_total}}</td>
                                <td>代理分账</td>
                                <td>{{$account->agent_total}}</td>
                                <td>
                                    <a href="/admin/examineBill/{{$account->time}}/agent">点击查看</a>
                                </td>
                            </tr>
                            <tr>
                                <td>审批结果</td>
                                <td colspan="7">
                                    <input type="button" value="通过" class="btn btn_input jump" report-type="1" report-id="{{$account->id}}">
                                    <input type="button" value="拒绝" report-id="{{$account->id}}" report-type="1" class="btn btn_input jujue">
                                </td>
                            </tr>
                        </table>
                    @endif
                    @if(($type == 0 || $type == 2) && $account->appoint_status == 0 && $account->appoint_total!=0)
                        <table border="1">
                            <tr>
                                <th>分账ID</th>
                                <th>分账期间</th>
                                <th>内部支出</th>
                                <th>分账总金额</th>
                                <th>分账类型</th>
                                <th>指定分账总金额</th>
                                <th>明细</th>
                            </tr>
                            <tr>
                                <td>{{$account->id}}</td>
                                <td>{{$account->time}}</td>
                                <td>{{$account->cost_total}}</td>
                                <td>{{$account->sp_total}}</td>
                                <td>指定分账</td>
                                <td>{{$account->appoint_total}}</td>
                                <td>
                                    <a href="/admin/examineBill/{{$account->time}}/appoint">点击查看</a>
                                </td>
                            </tr>
                            <tr>
                                <td>审批结果</td>
                                <td colspan="7">
                                    <input type="button" value="通过" class="btn btn_input jump" report-type="2" report-id="{{$account->id}}">
                                    <input type="button" value="拒绝" report-id="{{$account->id}}" report-type="2" class="btn btn_input jujue">
                                </td>
                            </tr>
                        </table>
                    @endif
                @endforeach
            </div>
            {{$accounts->links()}}
        </div>
    </div>
    <script src="{{URL::asset('js/finance/sub-accountStatement_route.js')}}"></script>
    <script>
        $("#account-type").change(function () {
            const typeValue = $("#account-type").val();
            if (typeValue) {
                window.location.href = 'http://' + HTTP_HOST + '/admin/financialRetrial/' + typeValue;
            }
        });
    </script>
@endsection

